<template>
  <div class="page-container">
    <div class="bg-gradient"></div>
    
    <div class="content">
      <!-- 添加关键词 -->
      <section class="card">
        <div class="card-header">
          <div>
            <h2><i class="fas fa-plus"></i> 批量添加关键词</h2>
            <p class="subtitle">选择日期后，可以同时为多个分类添加关键词</p>
          </div>
        </div>
        <div class="batch-add-form">
          <!-- 日期选择 -->
          <div class="date-selector">
            <label>选择日期：</label>
            <n-date-picker 
              v-model:value="batchDateValue" 
              type="date" 
              placeholder="请先选择日期"
              :format="dateFormat"
              size="large"
              style="width: 200px"
            />
          </div>
          
          <!-- 分类关键词输入表格 -->
          <div v-if="batchDate" class="batch-input-grid">
            <div 
              v-for="cat in categories" 
              :key="cat.id" 
              class="batch-input-row"
            >
              <div class="category-label">
                <span class="category-icon"><i class="fas fa-folder"></i></span>
                <span class="category-text">{{ cat.categoryName }}</span>
              </div>
              <input 
                v-model="batchKeywords[cat.id]" 
                type="text" 
                :placeholder="`输入${cat.categoryName}的关键词，用逗号分隔`"
                class="batch-input"
                @keyup.enter="batchAddKeywords"
              />
            </div>
          </div>
          
          <div v-else class="empty-hint">
            <span><i class="fas fa-hand-point-up"></i> 请先选择日期，然后为各个分类输入关键词</span>
          </div>
          
          <!-- 操作按钮 -->
          <div v-if="batchDate" class="batch-actions">
            <button class="btn-secondary" @click="clearBatchForm">清空</button>
            <button class="btn-primary" @click="batchAddKeywords">
              <i class="fas fa-check"></i> 批量添加
            </button>
          </div>
        </div>
      </section>

      <!-- 数据表格 -->
      <section class="card">
        <div class="card-header">
          <h2><i class="fas fa-clipboard-list"></i> 数据总览</h2>
          <button class="btn-secondary" @click="loadAllData" :disabled="isRefreshing">
            <i class="fas fa-sync" :class="{ 'fa-spin': isRefreshing }"></i> 
            {{ isRefreshing ? '加载中...' : '刷新' }}
          </button>
        </div>
        
        <div class="table-container">
          <table class="data-table">
            <thead>
              <tr>
                <th class="date-col">日期</th>
                <th v-for="cat in categories" :key="cat.id" class="category-col">
                  {{ cat.categoryName }}
                </th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(dateData, date) in groupedData" :key="date">
                <td class="date-cell">
                  <div class="date-content">
                    <span class="date-text">{{ formatDate(date) }}</span>
                    <button @click="deleteDateData(date)" class="delete-date-btn" title="删除该日所有数据">
                      <i class="fas fa-times"></i>
                    </button>
                  </div>
                </td>
                <td v-for="cat in categories" :key="cat.id" class="keyword-cell">
                  <div v-if="dateData[cat.id]" class="keyword-content">
                    <span class="keywords">{{ dateData[cat.id].keywords }}</span>
                    <div class="cell-actions">
                      <button @click="editKeyword(dateData[cat.id])" class="btn-xs" title="编辑"><i class="fas fa-pen"></i></button>
                      <button @click="deleteKeyword(dateData[cat.id].id)" class="btn-xs" title="删除"><i class="fas fa-trash"></i></button>
                    </div>
                  </div>
                  <span v-else class="empty-cell">-</span>
                </td>
              </tr>
              <tr v-if="Object.keys(groupedData).length === 0">
                <td :colspan="categories.length + 1" class="empty-row">
                  暂无数据
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </section>

      <!-- 重复数据统计 -->
      <section v-if="duplicateStats.length > 0" class="card">
        <div class="card-header">
          <h2><i class="fas fa-search"></i> 重复数据统计</h2>
        </div>
        
        <div class="duplicate-list">
          <div v-for="(item, index) in duplicateStats" :key="index" class="duplicate-item" :class="{ 'today-duplicate': item.hasTodayDuplicate }">
            <div class="duplicate-keyword">
              <span class="keyword-label">数据：</span>
              <span class="keyword-value" :class="{ 'today-highlight': item.hasTodayDuplicate }">{{ item.keyword }}</span>
              <span v-if="item.hasTodayDuplicate" class="today-badge">当日重复</span>
            </div>
            <div class="occurrence-tags">
              <span 
                v-for="(occ, oi) in item.occurrences" 
                :key="oi" 
                class="occurrence-tag"
                :class="{ 'today-occurrence': occ.isToday }"
              >
                {{ formatDate(occ.date) }} {{ occ.category }}
              </span>
            </div>
          </div>
        </div>
      </section>

      <!-- 分类管理按钮 -->
      <section class="card">
        <button class="btn-primary" @click="showCategoryListDialog = true" style="width: 100%">
          <i class="fas fa-folder-open"></i> 管理分类（{{ categories.length }}）
        </button>
      </section>
    </div>

    <!-- 分类列表对话框 -->
    <div v-if="showCategoryListDialog" class="modal" @click="showCategoryListDialog = false">
      <div class="modal-dialog" @click.stop>
        <div class="modal-header">
          <h3><i class="fas fa-folder-open"></i> 分类管理</h3>
          <button @click="showCategoryListDialog = false"><i class="fas fa-times"></i></button>
        </div>
        <div class="modal-body">
          <div style="margin-bottom: 15px">
            <button class="btn-primary" @click="openCategoryDialog()" style="width: 100%">
              + 新增分类
            </button>
          </div>
          <div class="category-list">
            <div v-for="cat in categories" :key="cat.id" class="category-item">
              <div class="category-info">
                <span class="category-name">{{ cat.categoryName }}</span>
                <span class="category-desc">{{ cat.description }}</span>
              </div>
              <div class="category-actions">
                <button @click="editCategory(cat)" class="btn-sm"><i class="fas fa-pen"></i></button>
                <button @click="deleteCategory(cat.id)" class="btn-sm"><i class="fas fa-trash"></i></button>
              </div>
            </div>
          </div>
          <div v-if="categories.length === 0" style="text-align: center; padding: 20px; color: #999;">
            暂无分类
          </div>
        </div>
      </div>
    </div>

    <!-- 分类编辑对话框 -->
    <div v-if="showCategoryDialog" class="modal" @click="closeCategoryDialog">
      <div class="modal-dialog" @click.stop>
        <div class="modal-header">
          <h3>{{ editingCategory.id ? '编辑分类' : '新增分类' }}</h3>
          <button @click="closeCategoryDialog"><i class="fas fa-times"></i></button>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label>分类名称</label>
            <input v-model="editingCategory.categoryName" placeholder="如：A组、B组" @keyup.enter="saveCategory" />
          </div>
          <div class="form-group">
            <label>备注说明</label>
            <textarea v-model="editingCategory.description" rows="3" placeholder="分类的备注说明"></textarea>
          </div>
          <div class="form-group">
            <label>排序顺序</label>
            <input v-model.number="editingCategory.sortOrder" type="number" placeholder="数字越小越靠前" />
          </div>
        </div>
        <div class="modal-footer">
          <button class="btn-secondary" @click="closeCategoryDialog">取消</button>
          <button class="btn-primary" @click="saveCategory">保存</button>
        </div>
      </div>
    </div>

    <!-- 关键词编辑对话框 -->
    <div v-if="showKeywordDialog" class="modal" @click="closeKeywordDialog">
      <div class="modal-dialog" @click.stop>
        <div class="modal-header">
          <h3>编辑关键词</h3>
          <button @click="closeKeywordDialog"><i class="fas fa-times"></i></button>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label>日期</label>
            <input :value="editingKeyword.dateStr" disabled />
          </div>
          <div class="form-group">
            <label>分类</label>
            <input :value="editingKeyword.categoryName" disabled />
          </div>
          <div class="form-group">
            <label>关键词</label>
            <input v-model="editingKeyword.keywords" placeholder="用逗号分隔" @keyup.enter="updateKeyword" />
          </div>
        </div>
        <div class="modal-footer">
          <button class="btn-secondary" @click="closeKeywordDialog">取消</button>
          <button class="btn-primary" @click="updateKeyword">保存</button>
        </div>
      </div>
    </div>

  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { useMessage, useDialog } from 'naive-ui'
import api from '../api'

// Naive UI APIs
const message = useMessage()
const dialog = useDialog()

// 状态
const categories = ref([])
const allKeywords = ref([])
const showCategoryDialog = ref(false)
const showKeywordDialog = ref(false)
const showCategoryListDialog = ref(false)
const editingCategory = ref({ id: null, categoryName: '', description: '', sortOrder: 0 })
const editingKeyword = ref({ id: null, dateStr: '', categoryId: null, categoryName: '', keywords: '' })
const newKeyword = ref({ dateStr: '', categoryId: null, keywords: '' })
const isRefreshing = ref(false)

// 批量添加状态
const batchDateValue = ref(null)
const batchKeywords = ref({})

// 日期格式化函数
const dateFormat = 'yyyy-MM-dd'
const batchDate = computed({
  get: () => {
    if (!batchDateValue.value) return ''
    const date = new Date(batchDateValue.value)
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    return `${year}-${month}-${day}`
  },
  set: (val) => {
    batchDateValue.value = val ? new Date(val).getTime() : null
  }
})

// 按日期和分类组织数据
const groupedData = computed(() => {
  const result = {}
  allKeywords.value.forEach(item => {
    if (!result[item.dateStr]) {
      result[item.dateStr] = {}
    }
    result[item.dateStr][item.categoryId] = item
  })
  // 按日期降序排序
  return Object.keys(result)
    .sort((a, b) => b.localeCompare(a))
    .reduce((obj, key) => {
      obj[key] = result[key]
      return obj
    }, {})
})

// 格式化日期
const formatDate = (dateStr) => {
  const date = new Date(dateStr)
  return `${date.getMonth() + 1}-${date.getDate()}`
}

// 判断日期字符串是否在当日范围内（今日9:00 - 明日9:00）
const isToday = (dateStr) => {
  const now = new Date()
  const currentHour = now.getHours()
  
  // 计算当日的开始时间（今日9:00或昨日9:00）
  const todayStart = new Date(now)
  if (currentHour < 9) {
    // 如果现在是0-8点，当日从昨天9点开始
    todayStart.setDate(todayStart.getDate() - 1)
  }
  todayStart.setHours(9, 0, 0, 0)
  
  // 计算当日的结束时间（明日9:00或今日9:00）
  const todayEnd = new Date(todayStart)
  todayEnd.setDate(todayEnd.getDate() + 1)
  todayEnd.setHours(9, 0, 0, 0)
  
  // 将日期字符串转换为日期对象（设置为当天的12:00，避免时区问题）
  const targetDate = new Date(dateStr)
  targetDate.setHours(12, 0, 0, 0)
  
  // 判断目标日期是否在当日范围内
  return targetDate >= todayStart && targetDate < todayEnd
}

// 重复数据统计
const duplicateStats = computed(() => {
  const keywordMap = new Map() // key: keyword, value: Array of {date, category}
  
  // 遍历所有关键词数据
  allKeywords.value.forEach(item => {
    if (!item.keywords) return
    
    // 分割关键词
    const keywords = item.keywords.split(/[,，]/).map(k => k.trim()).filter(k => k)
    
    keywords.forEach(keyword => {
      if (!keywordMap.has(keyword)) {
        keywordMap.set(keyword, [])
      }
      
      // 记录日期+分类组合
      keywordMap.get(keyword).push({
        date: item.dateStr,
        category: item.categoryName,
        dateCategory: `${item.dateStr} ${item.categoryName}`,
        isToday: isToday(item.dateStr)
      })
    })
  })
  
  // 筛选出重复出现的关键词（出现次数>=2）
  const result = []
  keywordMap.forEach((occurrences, keyword) => {
    if (occurrences.length >= 2) {
      // 检查当日是否有重复（当日范围内出现次数>=2）
      const todayOccurrences = occurrences.filter(occ => occ.isToday)
      const hasTodayDuplicate = todayOccurrences.length >= 2
      
      result.push({
        keyword,
        occurrences: occurrences.sort((a, b) => b.date.localeCompare(a.date)),
        hasTodayDuplicate // 新增标记，标识是否为当日重复
      })
    }
  })
  
  // 按关键词排序
  return result.sort((a, b) => a.keyword.localeCompare(b.keyword))
})

// 加载数据
const loadCategories = async () => {
  try {
    const response = await api.getCategories()
    // 按创建时间排序，新添加的在最后
    categories.value = response.data.sort((a, b) => {
      const timeA = new Date(a.createTime).getTime()
      const timeB = new Date(b.createTime).getTime()
      return timeA - timeB
    })
  } catch {
    message.error('加载分类失败')
  }
}

const loadAllKeywords = async () => {
  try {
    const response = await api.getAllKeywords()
    allKeywords.value = response.data
  } catch {
    message.error('加载数据失败')
  }
}


const loadAllData = async () => {
  isRefreshing.value = true
  try {
    await loadCategories()
    await loadAllKeywords()
  } finally {
    isRefreshing.value = false
  }
}

// 分类管理
const openCategoryDialog = () => {
  editingCategory.value = { id: null, categoryName: '', description: '', sortOrder: 0 }
  showCategoryDialog.value = true
}

const closeCategoryDialog = () => {
  showCategoryDialog.value = false
  showCategoryListDialog.value = false
}

const editCategory = (category) => {
  editingCategory.value = { ...category }
  showCategoryDialog.value = true
}

const saveCategory = async () => {
  if (!editingCategory.value.categoryName) {
    return message.warning('请输入分类名称')
  }
  try {
    if (editingCategory.value.id) {
      await api.updateCategory(editingCategory.value)
      message.success('修改成功')
    } else {
      await api.addCategory(editingCategory.value)
      message.success('添加成功')
    }
    closeCategoryDialog()
    loadCategories()
  } catch (error) {
    const errorMsg = error.response?.data?.message || error.message || '保存失败'
    dialog.error({
      title: '操作失败',
      content: errorMsg,
      positiveText: '确定'
    })
  }
}

const deleteCategory = async (id) => {
  dialog.warning({
    title: '删除确认',
    content: '确定要删除这个分类吗？如果该分类下有关键词数据，将无法删除。',
    positiveText: '确定删除',
    negativeText: '取消',
    onPositiveClick: async () => {
      try {
        await api.deleteCategory(id)
        message.success('删除成功')
        loadAllData()
      } catch (error) {
        const errorMsg = error.response?.data?.message || error.message || '删除失败'
        dialog.error({
          title: '删除失败',
          content: errorMsg,
          positiveText: '确定'
        })
      }
    }
  })
}

// 关键词管理
const addKeyword = async () => {
  if (!newKeyword.value.dateStr) return message.warning('请选择日期')
  if (!newKeyword.value.categoryId) return message.warning('请选择分类')
  if (!newKeyword.value.keywords) return message.warning('请输入关键词')
  
  const category = categories.value.find(c => c.id === newKeyword.value.categoryId)
  
  // 检查是否已存在相同的日期+分类组合
  const exists = allKeywords.value.some(
    item => item.dateStr === newKeyword.value.dateStr && 
            item.categoryId === newKeyword.value.categoryId
  )
  
  if (exists) {
    const existingKeyword = allKeywords.value.find(
      item => item.dateStr === newKeyword.value.dateStr && 
              item.categoryId === newKeyword.value.categoryId
    )
    
    dialog.warning({
      title: '数据已存在',
      content: `该日期（${newKeyword.value.dateStr}）下的${category.categoryName}已存在关键词：【${existingKeyword.keywords}】\n\n是否要修改现有关键词？`,
      positiveText: '去修改',
      negativeText: '取消',
      onPositiveClick: () => {
        // 用户选择去修改，打开编辑对话框
        editKeyword(existingKeyword)
      }
    })
    return
  }
  
  try {
    await api.addKeyword({
      dateStr: newKeyword.value.dateStr,
      categoryId: newKeyword.value.categoryId,
      categoryName: category.categoryName,
      keywords: newKeyword.value.keywords
    })
    message.success('添加成功')
    newKeyword.value = { dateStr: '', categoryId: null, keywords: '' }
    loadAllKeywords()
  } catch (error) {
    const errorMsg = error.response?.data?.message || error.message || '添加失败'
    dialog.error({
      title: '添加失败',
      content: errorMsg,
      positiveText: '确定'
    })
  }
}

// 批量添加关键词
const batchAddKeywords = async () => {
  if (!batchDate.value) {
    return message.warning('请先选择日期')
  }
  
  // 收集所有填写了关键词的分类
  const itemsToAdd = []
  const itemsToUpdate = []
  const existingItems = []
  
  for (const categoryId in batchKeywords.value) {
    const keywords = batchKeywords.value[categoryId]
    if (keywords && keywords.trim()) {
      const category = categories.value.find(c => c.id === Number(categoryId))
      if (!category) continue
      
      // 检查是否已存在
      const existing = allKeywords.value.find(
        item => item.dateStr === batchDate.value && item.categoryId === Number(categoryId)
      )
      
      if (existing) {
        existingItems.push({
          categoryName: category.categoryName,
          oldKeywords: existing.keywords,
          newKeywords: keywords,
          data: existing
        })
      } else {
        itemsToAdd.push({
          dateStr: batchDate.value,
          categoryId: Number(categoryId),
          categoryName: category.categoryName,
          keywords: keywords.trim()
        })
      }
    }
  }
  
  if (itemsToAdd.length === 0 && existingItems.length === 0) {
    return message.warning('请至少为一个分类输入关键词')
  }
  
  // 如果有已存在的数据，提示用户
  if (existingItems.length > 0) {
    const existingList = existingItems.map(item => 
      `【${item.categoryName}】: ${item.oldKeywords}`
    ).join('\n')
    
    return new Promise((resolve) => {
      dialog.warning({
        title: '部分数据已存在',
        content: `以下分类在该日期（${batchDate.value}）已存在关键词：\n\n${existingList}\n\n这些已存在的数据将被跳过，只添加新的数据。是否继续？`,
        positiveText: '继续添加新数据',
        negativeText: '取消',
        onPositiveClick: () => resolve(true),
        onNegativeClick: () => resolve(false)
      })
    }).then(async (shouldContinue) => {
      if (!shouldContinue) return
      await performBatchAdd(itemsToAdd)
    })
  } else {
    await performBatchAdd(itemsToAdd)
  }
}

// 执行批量添加的辅助函数
const performBatchAdd = async (itemsToAdd) => {
  let successCount = 0
  let failCount = 0
  const errors = []
  
  for (const item of itemsToAdd) {
    try {
      await api.addKeyword(item)
      successCount++
    } catch (error) {
      failCount++
      errors.push(`${item.categoryName}: ${error.response?.data?.message || '添加失败'}`)
    }
  }
  
  // 显示结果
  if (successCount > 0) {
    message.success(`成功添加 ${successCount} 个分类的关键词`)
    clearBatchForm()
    loadAllKeywords()
  }
  
  if (failCount > 0) {
    const dialogType = failCount === itemsToAdd.length ? 'error' : 'warning'
    dialog[dialogType]({
      title: '批量添加结果',
      content: `成功：${successCount} 个\n失败：${failCount} 个\n\n失败详情：\n${errors.join('\n')}`,
      positiveText: '确定'
    })
  }
}

// 清空批量添加表单
const clearBatchForm = () => {
  batchKeywords.value = {}
  batchDateValue.value = null
}

const editKeyword = (keyword) => {
  editingKeyword.value = { ...keyword }
  showKeywordDialog.value = true
}

const closeKeywordDialog = () => {
  showKeywordDialog.value = false
}

const updateKeyword = async () => {
  if (!editingKeyword.value.keywords) return message.warning('请输入关键词')
  try {
    await api.updateKeyword(editingKeyword.value)
    message.success('更新成功')
    closeKeywordDialog()
    loadAllKeywords()
  } catch (error) {
    const errorMsg = error.response?.data?.message || error.message || '更新失败'
    dialog.error({
      title: '更新失败',
      content: errorMsg,
      positiveText: '确定'
    })
  }
}

const deleteKeyword = async (id) => {
  dialog.warning({
    title: '删除确认',
    content: '确定要删除这条关键词数据吗？删除后将无法恢复。',
    positiveText: '确定删除',
    negativeText: '取消',
    onPositiveClick: async () => {
      try {
        await api.deleteKeyword(id)
        message.success('删除成功')
        loadAllKeywords()
      } catch (error) {
        const errorMsg = error.response?.data?.message || error.message || '删除失败'
        dialog.error({
          title: '删除失败',
          content: errorMsg,
          positiveText: '确定'
        })
      }
    }
  })
}

// 删除某一日的所有数据
const deleteDateData = async (dateStr) => {
  // 获取该日期下的所有数据
  const dateKeywords = allKeywords.value.filter(item => item.dateStr === dateStr)
  
  if (dateKeywords.length === 0) {
    return message.warning('该日期下没有数据')
  }
  
  // 生成分类列表用于显示
  const categoryList = dateKeywords.map(item => item.categoryName).join('、')
  
  dialog.warning({
    title: '删除确认',
    content: `确定要删除 ${formatDate(dateStr)}（${dateStr}）的所有数据吗？\n\n将删除以下分类的数据：${categoryList}\n\n共 ${dateKeywords.length} 条数据，删除后将无法恢复。`,
    positiveText: '确定删除',
    negativeText: '取消',
    onPositiveClick: async () => {
      let successCount = 0
      let failCount = 0
      const errors = []
      
      // 批量删除该日期下的所有数据
      for (const item of dateKeywords) {
        try {
          await api.deleteKeyword(item.id)
          successCount++
        } catch (error) {
          failCount++
          errors.push(`${item.categoryName}: ${error.response?.data?.message || '删除失败'}`)
        }
      }
      
      // 显示结果
      if (successCount > 0) {
        message.success(`成功删除 ${successCount} 条数据`)
        loadAllKeywords()
      }
      
      if (failCount > 0) {
        dialog.error({
          title: '删除结果',
          content: `成功：${successCount} 条\n失败：${failCount} 条\n\n失败详情：\n${errors.join('\n')}`,
          positiveText: '确定'
        })
      }
    }
  })
}

onMounted(() => {
  loadAllData()
})
</script>

<style scoped>
/* 枫叶风格配色系统 */
:root {
  --maple-primary: #E8927C;
  --maple-secondary: #F4C193;
  --maple-accent: #D97757;
  --maple-light: #FFE8DB;
  --maple-cream: #FFF8F3;
  --maple-text: #5C4742;
  --maple-text-light: #8B6F66;
  --maple-success: #A8D5BA;
  --maple-danger: #E89A8C;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.page-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #FFF8F3 0%, #FFE8DB 50%, #FFD7C7 100%);
  padding: 20px;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

.page-container::before {
  content: '';
  position: fixed;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(232, 146, 124, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

.page-container::after {
  content: '';
  position: fixed;
  bottom: -30%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(244, 193, 147, 0.12) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

.bg-gradient {
  display: none;
}

.content {
  max-width: 1280px;
  margin: 0 auto;
  animation: contentFadeIn 0.5s ease;
  position: relative;
  z-index: 1;
}

@keyframes contentFadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 头部 */
.header {
  text-align: center;
  padding: 48px 32px;
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.12);
  border: 2px solid rgba(232, 146, 124, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(232, 146, 124, 0.18);
}

.header h1 {
  font-size: 36px;
  background: linear-gradient(135deg, #E8927C 0%, #D97757 50%, #E8927C 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header h1 i {
  background: linear-gradient(135deg, #E8927C 0%, #D97757 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: 12px;
}

.header p {
  font-size: 16px;
  color: var(--maple-text-light);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* 卡片 */
.card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  margin-bottom: 32px;
  padding: 36px;
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 2px solid rgba(232, 146, 124, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
  overflow: visible;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #E8927C 0%, #F4C193 50%, #E8927C 100%);
  border-radius: 24px 24px 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card::after {
  content: '🍁';
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 40px;
  opacity: 0.08;
  transform: rotate(15deg);
  pointer-events: none;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(232, 146, 124, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  border-color: rgba(232, 146, 124, 0.25);
}

.card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 3px solid;
  border-image: linear-gradient(90deg, rgba(232, 146, 124, 0.2) 0%, rgba(244, 193, 147, 0.2) 50%, rgba(232, 146, 124, 0.2) 100%) 1;
}

.card-header h2 {
  font-size: 26px;
  color: var(--maple-text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 14px;
  letter-spacing: 0.5px;
  position: relative;
}

.card-header h2::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, #E8927C 0%, #F4C193 100%);
  border-radius: 2px;
  opacity: 0.7;
}

.card-header h2 i {
  color: var(--maple-primary);
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(232, 146, 124, 0.3));
  animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.subtitle {
  font-size: 14px;
  color: var(--maple-text-light);
  margin-top: 6px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* 按钮 */
button {
  padding: 13px 26px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 3px 10px rgba(232, 146, 124, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color: var(--maple-text);
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease;
}

button:hover::after {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(232, 146, 124, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 6px rgba(232, 146, 124, 0.15);
}

.btn-primary {
  background: linear-gradient(135deg, #E8927C 0%, #D97757 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(232, 146, 124, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #D97757 0%, #C86647 100%);
  box-shadow: 0 6px 20px rgba(232, 146, 124, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-secondary {
  background: #A8D5BA;
  color: #fff;
  box-shadow: 0 3px 10px rgba(168, 213, 186, 0.25);
}

.btn-secondary:hover {
  background: #8BC5A4;
  box-shadow: 0 5px 16px rgba(168, 213, 186, 0.35);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.fa-spin {
  animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
  font-weight: 500;
}

.btn-xs {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 500;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-xs i {
  font-size: 12px;
}

.btn-xs:hover {
  transform: scale(1.1) !important;
}

.btn-xs:active {
  transform: scale(0.95) !important;
}

.btn-xs::after {
  display: none;
}

.btn-danger {
  background: #E89A8C;
  color: #fff;
  box-shadow: 0 3px 10px rgba(232, 154, 140, 0.25);
}

.btn-danger:hover {
  background: #D97867;
  box-shadow: 0 5px 16px rgba(232, 154, 140, 0.35);
}

/* 分类列表 */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(232, 146, 124, 0.1);
  box-shadow: 0 2px 8px rgba(232, 146, 124, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  border-left: 4px solid transparent;
}

.category-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(232, 146, 124, 0.15);
  border-color: rgba(232, 146, 124, 0.25);
  border-left-color: #E8927C;
}

.category-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-name {
  font-weight: 700;
  color: var(--maple-text);
  font-size: 15px;
  letter-spacing: 0.3px;
}

.category-desc {
  font-size: 13px;
  color: var(--maple-text-light);
  line-height: 1.5;
}

.category-actions {
  display: flex;
  gap: 8px;
}

/* 批量添加表单 */
.batch-add-form {
  background: rgba(255, 248, 243, 0.7);
  padding: 24px;
  border-radius: 16px;
  border: 2px solid rgba(232, 146, 124, 0.15);
}

.date-selector {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.date-selector label {
  font-size: 16px;
  font-weight: 700;
  color: var(--maple-text);
  letter-spacing: 0.3px;
}

.batch-input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.batch-input-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 248, 243, 0.9) 100%);
  border-radius: 14px;
  border: 2px solid rgba(232, 146, 124, 0.12);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.batch-input-row::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, #E8927C 0%, #F4C193 100%);
  border-radius: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.batch-input-row:hover {
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.15);
  transform: translateY(-2px);
}

.batch-input-row:hover::before {
  opacity: 0.3;
}

.category-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-icon {
  font-size: 20px;
  color: var(--maple-primary);
  filter: drop-shadow(0 2px 4px rgba(232, 146, 124, 0.3));
  animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.category-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--maple-text);
  letter-spacing: 0.3px;
}

.batch-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid rgba(232, 146, 124, 0.2);
  border-radius: 12px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--maple-text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.batch-input:hover {
  border-color: rgba(232, 146, 124, 0.35);
}

.batch-input:focus {
  outline: none;
  border-color: var(--maple-primary);
  box-shadow: 0 0 0 4px rgba(232, 146, 124, 0.12), inset 0 1px 3px rgba(0, 0, 0, 0.05);
  background: #fff;
  transform: translateY(-1px);
}

.batch-input::placeholder {
  color: var(--maple-text-light);
  opacity: 0.5;
  font-style: italic;
}

.empty-hint {
  text-align: center;
  padding: 56px 32px;
  color: var(--maple-text-light);
  background: linear-gradient(135deg, rgba(255, 248, 243, 0.8) 0%, rgba(255, 232, 219, 0.6) 100%);
  border: 3px dashed rgba(232, 146, 124, 0.3);
  border-radius: 18px;
  font-size: 16px;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.empty-hint::before {
  content: '🍂';
  position: absolute;
  top: 15px;
  left: 20px;
  font-size: 30px;
  opacity: 0.15;
  transform: rotate(-15deg);
}

.empty-hint::after {
  content: '🍂';
  position: absolute;
  bottom: 15px;
  right: 20px;
  font-size: 30px;
  opacity: 0.15;
  transform: rotate(15deg);
}

.empty-hint i {
  color: var(--maple-primary);
  font-size: 24px;
  margin-right: 10px;
  animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.batch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 2px solid rgba(232, 146, 124, 0.15);
  flex-wrap: wrap;
}

/* 表格 */
.table-container {
  overflow-x: auto;
  border-radius: 16px;
  border: 2px solid rgba(232, 146, 124, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

/* 隐藏滚动条 */
.table-container::-webkit-scrollbar {
  display: none;
}

.table-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
  min-width: 600px;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(232, 146, 124, 0.1);
  text-align: left;
  vertical-align: top;
}

.data-table thead {
  background: linear-gradient(135deg, rgba(232, 146, 124, 0.12) 0%, rgba(244, 193, 147, 0.1) 100%);
  position: relative;
}

.data-table thead::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, #E8927C 50%, transparent 100%);
  opacity: 0.5;
}

.data-table thead th {
  font-weight: 700;
  color: var(--maple-text);
  font-size: 16px;
  letter-spacing: 0.5px;
  border-bottom: none;
  text-transform: uppercase;
  font-size: 13px;
  padding: 18px 16px;
}

.data-table thead th:first-child {
  border-top-left-radius: 14px;
}

.data-table thead th:last-child {
  border-top-right-radius: 14px;
}

.data-table tbody tr {
  transition: all 0.3s ease;
}

.data-table tbody tr:hover {
  background: linear-gradient(90deg, rgba(232, 146, 124, 0.08) 0%, rgba(244, 193, 147, 0.06) 50%, rgba(232, 146, 124, 0.08) 100%);
}

.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 14px;
}

.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 14px;
}

.date-cell {
  font-weight: 700;
  background: linear-gradient(135deg, rgba(255, 248, 243, 0.8) 0%, rgba(255, 232, 219, 0.6) 100%);
  white-space: nowrap;
  padding: 0 !important;
  color: var(--maple-text);
}

.date-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  position: relative;
}

.date-text {
  flex: 1;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.delete-date-btn {
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 6px 10px;
  font-size: 14px;
  background: linear-gradient(135deg, #E89A8C 0%, #D97867 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-left: 12px;
  box-shadow: 0 2px 8px rgba(232, 154, 140, 0.2);
  font-weight: 600;
}

.delete-date-btn:hover {
  background: linear-gradient(135deg, #D97867 0%, #C86757 100%);
  box-shadow: 0 4px 12px rgba(232, 154, 140, 0.4);
  transform: scale(1.05);
}

.delete-date-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(232, 154, 140, 0.3);
}

.date-cell:hover .delete-date-btn {
  opacity: 1;
}

.keyword-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.keywords {
  color: var(--maple-text);
  font-size: 14px;
  line-height: 1.8;
  word-break: break-all;
  white-space: pre-wrap;
  flex: 1;
}

.cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.keyword-content:hover .cell-actions {
  opacity: 1;
}

.empty-cell {
  color: var(--maple-text-light);
  opacity: 0.4;
  font-size: 18px;
}

.empty-row {
  text-align: center;
  padding: 48px;
  color: var(--maple-text-light);
  font-size: 16px;
  font-weight: 500;
}

/* 重复数据 */
.duplicate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.duplicate-item {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(232, 146, 124, 0.15);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(232, 146, 124, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.duplicate-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.15);
}

.duplicate-keyword {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keyword-label {
  font-size: 12px;
  color: var(--maple-text-light);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.keyword-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--maple-accent);
  word-break: break-all;
  letter-spacing: 0.3px;
}

.occurrence-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.occurrence-tag {
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(232, 146, 124, 0.15) 0%, rgba(244, 193, 147, 0.1) 100%);
  border: 2px solid rgba(232, 146, 124, 0.25);
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  color: var(--maple-text);
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.occurrence-tag::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s ease;
}

.occurrence-tag:hover {
  background: linear-gradient(135deg, rgba(232, 146, 124, 0.25) 0%, rgba(244, 193, 147, 0.2) 100%);
  border-color: rgba(232, 146, 124, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(232, 146, 124, 0.2);
}

.occurrence-tag:hover::before {
  left: 100%;
}

/* 当日重复数据标红样式 */
.today-duplicate {
  border-color: rgba(232, 77, 77, 0.3);
  background: rgba(255, 245, 245, 0.95);
}

.today-duplicate:hover {
  border-color: rgba(232, 77, 77, 0.5);
  box-shadow: 0 4px 16px rgba(232, 77, 77, 0.2);
}

.today-highlight {
  color: #E84D4D !important;
  font-weight: 800;
}

.today-badge {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, #E84D4D 0%, #D93636 100%);
  color: #fff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(232, 77, 77, 0.3);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.today-occurrence {
  background: linear-gradient(135deg, rgba(232, 77, 77, 0.15) 0%, rgba(255, 200, 200, 0.15) 100%);
  border-color: rgba(232, 77, 77, 0.4);
  color: #E84D4D;
  font-weight: 700;
}

.today-occurrence:hover {
  background: linear-gradient(135deg, rgba(232, 77, 77, 0.25) 0%, rgba(255, 200, 200, 0.25) 100%);
  border-color: rgba(232, 77, 77, 0.6);
  box-shadow: 0 4px 12px rgba(232, 77, 77, 0.3);
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(92, 71, 66, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-dialog {
  background: rgba(255, 255, 255, 0.98);
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  border-radius: 20px;
  border: 2px solid rgba(232, 146, 124, 0.2);
  box-shadow: 0 10px 40px rgba(232, 146, 124, 0.25);
  animation: modalSlideUp 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 2px solid rgba(232, 146, 124, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(232, 146, 124, 0.06);
}

.modal-header h3 {
  font-size: 18px;
  color: var(--maple-text);
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h3 i {
  color: var(--maple-primary);
}

.modal-header button {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(232, 146, 124, 0.1);
  border-radius: 8px;
  cursor: pointer;
  color: var(--maple-accent);
  font-size: 16px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header button:hover {
  background: rgba(232, 146, 124, 0.2);
  transform: rotate(90deg);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: rgba(232, 146, 124, 0.1);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(232, 146, 124, 0.3);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 146, 124, 0.5);
}

.modal-footer {
  padding: 16px 20px;
  border-top: 2px solid rgba(232, 146, 124, 0.15);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(255, 248, 243, 0.4);
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--maple-text);
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 2px solid rgba(232, 146, 124, 0.2);
  border-radius: 10px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--maple-text);
  transition: all 0.3s ease;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--maple-primary);
  box-shadow: 0 0 0 3px rgba(232, 146, 124, 0.15);
  background: #fff;
}

.form-group input:disabled {
  background: rgba(232, 146, 124, 0.05);
  color: var(--maple-text-light);
  cursor: not-allowed;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* 响应式 - 平板端 */
@media (max-width: 1024px) {
  .duplicate-list {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .batch-input-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

/* 响应式 - 移动端 */
@media (max-width: 768px) {
  .page-container {
    padding: 12px;
  }
  
  .header {
    padding: 32px 20px;
    margin-bottom: 24px;
    border-radius: 20px;
  }
  
  .header h1 {
    font-size: 28px;
  }
  
  .header p {
    font-size: 14px;
  }
  
  .card {
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 16px;
  }
  
  .card-header h2 {
    font-size: 20px;
  }
  
  .category-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
  }
  
  .batch-input-grid {
    grid-template-columns: 1fr;
  }
  
  .batch-add-form {
    padding: 20px;
  }
  
  .duplicate-list {
    grid-template-columns: 1fr;
  }
  
  .batch-actions {
    flex-direction: column;
  }
  
  .batch-actions button {
    width: 100%;
  }
  
  button {
    padding: 12px 20px;
  }
  
  .data-table {
    font-size: 14px;
  }
  
  .data-table th,
  .data-table td {
    padding: 12px;
  }
  
  .delete-date-btn {
    opacity: 1;
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .modal-dialog {
    border-radius: 20px;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .page-container {
    padding: 10px;
  }
  
  .header {
    padding: 24px 16px;
    border-radius: 16px;
  }
  
  .header h1 {
    font-size: 24px;
  }
  
  .header p {
    font-size: 13px;
  }
  
  .card {
    padding: 16px;
    border-radius: 14px;
  }
  
  .card-header h2 {
    font-size: 18px;
  }
  
  .card-header h2 i {
    font-size: 20px;
  }
  
  .data-table {
    font-size: 13px;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }
  
  .date-content {
    padding: 10px 8px;
  }
  
  .delete-date-btn {
    opacity: 1;
    padding: 4px 8px;
    font-size: 12px;
  }
  
  .btn-xs {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .category-item {
    padding: 14px;
  }
  
  .batch-add-form {
    padding: 16px;
  }
  
  .batch-input-row {
    padding: 12px;
  }
  
  .duplicate-list {
    grid-template-columns: 1fr;
  }
  
  .duplicate-item {
    padding: 16px;
  }
  
  .occurrence-tags {
    gap: 6px;
  }
  
  .occurrence-tag {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .modal-dialog {
    max-width: 100%;
    border-radius: 16px;
  }
  
  .modal-header h3 {
    font-size: 18px;
  }
}
</style>
